package com.aimei520.controller.converter;

import org.springframework.core.convert.converter.Converter;

/**
 * 用户输入的字符串进行前后去掉空格
 * <p>Title: StringTrimConverter.java</p>  
 * <p>Description: </p>  
 * <p>Copyright: Copyright (c) 2018</p>  
 * <p>Company: www.storyboy.xyz</p>  
 * @author JiaXun  
 * @date 2018年8月29日  
 * @version 1.0.0
 */
public class StringTrimConverter implements Converter<String, String> {

	@Override
	public String convert(String source) {
		try {
			//去掉字符串两边空格，如果去除后为空设置为null
			if(source==null)
				return null;
			
			source = source.trim();
			
			if(source.equals(""))
				return null;
			
			return source;
			
		} catch (Exception e) {
			e.fillInStackTrace();
		}
		
		return null;
		
	}

}
